package com.automobile.dao;

import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.automobile.domain.Site;

//@CacheNamespace(blocking = true)
@Repository
public interface SiteDao {
	
	@Select("select * from site where id = #{siteId}")
	Site findSiteById(int siteId);//根据Id
	
	@Select("select * from site where userid = #{userId}")
	List<Site> findSiteByUserId(int userId);
	
	@Insert("insert into site(name,phone,province,city,region,detailed,isDefault,userId) "
			+ "values(#{name},#{phone},#{province},#{city},#{region},#{detailed},#{isDefault},#{userId})")
	void save(Site site);//保存
	
	@Update("update site set name = #{name} ,"
						  + "phone = #{phone} ,"
						  + "province = #{province} ,"
						  + "city = #{city},"
						  + "region = #{region},"
						  + "detailed = #{detailed},"
						  + "isDefault = #{isDefault} "
						  + "where id = #{id}")
	void update(Site site);//更新
	
	@Delete("delete form site where id = #{id}")
	void delete(int id);//删除
	
}
